Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_OPPO_CustomAdMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.CustomAds = new Map();
    this.CustomAdOpen = new Map();
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this58 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 120;
      if (!(window.qg.getSystemInfoSync().minPlatformVersion < 1094 && window.qg.createCustomAd) && (console.log("创建原生模板广告-------:", e), window.qg && !this.CustomAds.has(e))) {
        console.log("CustomAds---1---", e);
        var _t27 = .9 * window.qg.getSystemInfoSync().windowWidth;
        var _n22 = window.qg.getSystemInfoSync().windowHeight - .65625 * _t27;
        var _o58 = (window.qg.getSystemInfoSync().windowWidth - _t27) / 2;
        console.log("top66", _n22);
        console.log("left", _o58);
        console.log("width", _t27);
        var _i15 = window.qg.createCustomAd({
          adUnitId: e,
          style: {
            top: _n22,
            left: _o58,
            width: _t27
          }
        });
        _i15.onLoad(function (e) {
          console.log("原生模板广告加载成功", e);
        });
        _i15.onError(function (t) {
          _this58.CustomAdOpen.set(e, false);
          _this58.Destroy(e);
          console.log("原生模板广告加载错误", JSON.stringify(t));
        });
        _i15.offShow(function () {
          console.log("原生模板广告关闭 onClose");
          _this58.CustomAdOpen.set(e, false);
        });
        _i15.onHide(function () {
          console.log("原生模板广告关闭 onHide");
          _this58.CustomAdOpen.set(e, false);
        });
        this.CustomAds.set(e, _i15);
      }
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      var _this59 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 120;
      console.log("CustomAd:", this.CustomAds.get(e), this.CustomAdOpen.get(e));
      this.CustomAds.has(e) || this.Create(e, t, n);
      if (this.CustomAdOpen.get(e)) {
        console.log("显示中------");
      } else {
        console.log("CustomAd Show----------");
        this.CustomAdOpen.set(e, true);
        this.CustomAds.get(e).show().then(function () {
          0 == _this59.CustomAdOpen.get(e) && _this59.Hide(e);
          console.log("原生广告显示");
        }).catch(function (t) {
          _this59.CustomAdOpen.set(e, false);
          console.log("原生广告显示失败", t);
        });
      }
    }
  }, {
    key: "Hide",
    value: function Hide(e) {
      console.log("隐藏原生广告+++++", e);
      this.CustomAdOpen.set(e, false);
      this.CustomAds.has(e) && this.CustomAds.get(e).hide();
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      console.log("销毁原生广告:", e);
      if (this.CustomAds.has(e)) {
        this.CustomAds.get(e).offError();
        this.CustomAds.get(e).offClose();
        this.CustomAds.get(e).offHide();
        this.CustomAds.get(e).destroy();
        this.CustomAds.delete(e);
      }
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_OPPO_CustomAdMgr;